<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01mixin</title>
  <script src="../../js/vue.js"></script>
</head>

<body>
  <div id="app">
  </div>
  <script>
    var vm = new Vue({
      el: '#app'
    })
    // 定义一个混入对象
    var myMixin = {
      created: function () {
        this.hello()
      },
      methods: {
        hello: function () {
          console.log('hello from mixin!')
        }
      }
    }
    // 定义一个使用混入对象的组件
    var Component = Vue.extend({
      mixins: [myMixin]
    })
    var component = new Component() // => "hello from mixin!"

  </script>
</body>

</html>